<script type="text/javascript">
  jQuery(function($){
    $('#re_password').blur(function(){
      var n = $("input:checked").val();
      var iTotalChar = 0;
      var tTotalChar = 6;
      
      iTotalChar = $('#ds_password').val();
      
      if(n != 1){
        if($('#ds_password').val() != $('#re_password').val()){
          $("#verify").show();
          $("#div_verify").text("As senhas estão diferente");
        }  
        else if($('#ds_password').val().length < tTotalChar){
          $("#verify").show();  
          $("#div_verify").text("Valor do campo 'Senha' dever tem no mínimo " + tTotalChar + " caractéres!");
        }
        else if($('#re_password').val().length < tTotalChar){
          $("#verify").show();
          $("#div_verify").text("Valor do campo 'Repetir Senha' dever tem no mínimo " + tTotalChar + " caractéres!");
        }
        else{
          $("#verify").hide();
        }  
      }
    });
  });  

  jQuery(function($){
    $('#form1').submit(function(){
      if($('#idOrganization').val() == ""){
        $("#verify").show();
        $("#div_verify").text("Selecione uma Organização");
        
        return false;
      }

      if($('#idProfile').val() == ""){
        $("#verify").show();
        $("#div_verify").text("Selecione um Perfil de Acesso");
        
        return false;
      }

      if($('#ds_member').val() == ""){
        $("#verify").show();
        $("#div_verify").text("Nome do Usuário é obrigatório.");
        
        return false;
      }

      if($('#ds_email').val() == ""){
        $("#verify").show();
        $("#div_verify").text("E-mail é obrigatório.");
          
        return false;
      }

      if($('#ds_login').val() == ""){
        $("#verify").show();
        $("#div_verify").text("Login é obrigatório.");
        
        return false;
      }

      if($('#ds_password').val() == ""){
        $("#verify").show();
        $("#div_verify").text("Senha é obrigatório.");

        return false;
      }
    });
  });
</script>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="margin-top: 30px; margin-bottom: 30px; padding-left: 30px; padding-right: 30px;">
  <tr>
    <td style="vertical-align: top;">
      <table border="0" cellpadding="0" cellspacing="0" align="center" width="100%">
        <tr>
			    <td class="label_page" width="150" align="center">
			      <span>Adicionar Novo Usuário</span>
			    </td>
			    <td>&nbsp;</td>
			  </tr>
			  <tr>
			    <td align="center" colspan="2" class="content_page">
			      <form name="form1" id="form1" method="POST" action="<?php echo $this->baseUrl?>/members/insert-member">
				      <table border="0" cellpadding="0" cellspacing="4" align="left" width="100%">
				        <tr id="verify">
				          <td align="center" colspan="2">
				            <div id="div_verify" style="padding: 10px;"></div>
				          </td>
				        </tr>
				        
				        <tr>
				          <td align="right" class="label">Organização:</td>
				          <td align="left">
				            <select name="idOrganization" id="idOrganization" class="select">
				              <option value="">Selecione</option>
				              <?php 
				                foreach($this->organizations as $orgs){
				                	$orgs = (object)$orgs;
				                	?>
				                	<option value="<?php echo $orgs->idOrganization?>"><?php echo $orgs->ds_organization?></option>
				                	<?php
				                }
				              ?>
				            </select>
				            <b style="color: #FF0000">*</b>
				          </td>
				        </tr>
				        <tr>
				          <td align="right" class="label">Perfil de acesso:</td>
				          <td align="left">
				            <select name="idProfile" id="idProfile" class="select">
				              <option value="">Selecione</option>
				              <?php 
				                foreach($this->profiles as $profs){
				                  $profs = (object)$profs;
				                  ?>
				                  <option value="<?php echo $profs->idProfile?>"><?php echo utf8_encode($profs->ds_profile)?></option>
				                  <?php
				                }
				              ?>
				            </select>
				            <b style="color: #FF0000">*</b>
				          </td>
				        </tr>
				        <tr>
				          <td align="right" class="label">Nome do Usuário:</td>
				          <td align="left">
				            <input type="text" name="ds_member" id="ds_member" class="text_field" size="40" maxlength="100"/>
				            <b style="color: #FF0000">*</b>
				          </td>
				        </tr>
				        
				        <tr>
			            <td align="right" class="label">E-mail:</td>
			            <td align="left">
			              <input type="text" name="ds_email" id="ds_email" class="text_field" size="40" maxlength="120"/>
			              <b style="color: #FF0000">*</b>
			            </td>
			          </tr>
				        
				        <tr>
				          <td align="right" class="label">Login:</td>
				          <td align="left">
				            <input type="text" name="ds_login" id="ds_login" class="text_field" size="40" maxlength="40"/>
				            <b style="color: #FF0000">*</b>
				          </td>
				        </tr>
				        
				        <tr>
				          <td align="right" class="label">Inserir Senha Padrão:</td>
				          <td align="left">
				            <input type="checkbox" name="pwd_default" id="pwd_default" value="1"/>
				          </td>
				        </tr>
				        
				        <tr>
				          <td align="right" class="label">Senha:</td>
				          <td align="left">
				            <input type="password" name="ds_password" id="ds_password" class="text_field" size="40" maxlength="15"/>
				            <b style="color: #FF0000">*</b>
				            <span style="font-size: 11px; color: #999;">- Somente Letras e números, no minimo 6 e no máximo 15 caracteres.</span>
				          </td>
				        </tr>
				        
				        <tr id="row_repass">
				          <td align="right" class="label">Repetir Senha:</td>
				          <td align="left">
				            <input type="password" name="re_password" id="re_password" class="text_field" size="40" maxlength="15"/>
				            <b style="color: #FF0000">*</b>
				          </td>
				        </tr>
				        
				        <tr>
				          <td align="right" class="label">Ativado:</td>
				          <td align="left">
				            <input type="checkbox" name="chk_st_member" id="chk_st_member" checked="checked" disabled="disabled"/>
				            <input type="hidden" name="st_member" id="st_member" value="1"/>
				          </td>
				        </tr>
				        
				        <tr>
				          <td colspan="2" height="15">&nbsp;</td>
				        </tr>
				        
				        <tr>
				          <td colspan="2" align="center">
				            <input type="submit" id="btn_submit" value="Salvar" class="button"/>
				          </td>
				        </tr>
				      </table>
				    </form>  
			    </td>
			  </tr>
			  <tr>
			    <td class="label" colspan="2">
			      (<b style="color: #FF0000">*</b>) - Campos Obrigatórios.
			    </td>
			  </tr>
			</table>
		</td>
	</tr>		    
</table>